import { BasicColumn, BasicTable, FormSchema, useTable } from "@/components/Table";
import Toolbar from "@/components/ViewComponents/Toolbar";
import { useTranslation } from "react-i18next";
import CreateAndUpdata from "./components/createAndUpdata/index";
import { useDrawer } from "@/components/Drawer";
const index = () => {
	const { t } = useTranslation();
	const en_vi = "Hospitalization.surgerySchedule";
	const columns: BasicColumn[] = [
		{
			title: t(`${en_vi}.packageApproval`),
			dataIndex: "PackageApproval" //包审批
		},
		{
			title: t(`${en_vi}.date`),
			dataIndex: "Date" //日期
		},
		{
			title: t(`${en_vi}.department`),
			dataIndex: "Department" //科室
		},
		{
			title: t(`${en_vi}.operatingRoom`),
			dataIndex: "OperatingRoom" //手术室
		},
		{
			title: t(`${en_vi}.serialNumber`),
			dataIndex: "SerialNumber" //序列号
		},
		{
			title: t(`${en_vi}.patientAdmissionDateTime`),
			dataIndex: "Patient" //患者入院日期和时间
		},
		{
			title: t(`${en_vi}.surgeryStartDateTime`),
			dataIndex: "Surgery" //手术开始日期和时间
		},
		{
			title: t(`${en_vi}.desiredDateTimeFromSurgeon`),
			dataIndex: "Desired" //主刀医生期望的日期和时间
		},
		{
			title: t(`${en_vi}.duration`),
			dataIndex: "Duration" //持续时间
		},
		{
			title: t(`${en_vi}.surgeon`),
			dataIndex: "Surgeon" //主刀医生
		},
		{
			title: t(`${en_vi}.assistantSurgeon`),
			dataIndex: "AssistantSurgeon" //助手医生
		},
		{
			title: t(`${en_vi}.anesthesiologist`),
			dataIndex: "Anesthesiologist" //麻醉师
		},
		{
			title: t(`${en_vi}.patientCode`),
			dataIndex: "PatientCode" //患者编码
		},
		{
			title: t(`${en_vi}.fullName`),
			dataIndex: "FullName" //姓名
		}
	];
	const schemas: FormSchema[] = [
		{
			label: t(`${en_vi}.surgeryScheduleFrom`),
			field: "Surgery ", //手术开始时间
			component: "DatePicker"
		},
		{
			label: t(`${en_vi}.to`),
			field: "To ", //手术结束时间
			component: "DatePicker"
		},
		{
			label: t(`${en_vi}.department`),
			field: "Department ", //科室
			component: "Select"
		}
	];
	const [register] = useTable({
		columns,
		useSearchForm: true,
		formConfig: {
			labelWidth: 150,
			schemas,
			showActionButtonGroup: true,
			baseColProps: { span: 7 },
			actionColOptions: { span: 24 }
		},
		bordered: true
	});
	const [registerDrawer, { openDrawer }] = useDrawer();
	const handlerToolbarAction = (key: string) => {
		switch (key) {
			case "add":
				openDrawer(true);
				break;
		}
	};
	return (
		<div className="page">
			<div className="page-content">
				<BasicTable register={register}></BasicTable>
				<CreateAndUpdata register={registerDrawer}></CreateAndUpdata>
			</div>
			<Toolbar action={handlerToolbarAction} btnList={["add"]} />
		</div>
	);
};
export default index;
